Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor BaseProxy __init__ method #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sorce
Copy link

@sorce sorce commented Aug 28, 2017

This pull request refactors some of the BaseProxy __init__ methods code to better support the reading in of RPC credentials.

Currently the code will only attempt to read in a cookie file if a configuration file exists and a valid rpcpassword variable is not found in it. This change will fail silently if the configuration file does not exist or is unable to be read (permission issue, etc.), continuing on to try to read a cookie file. if we are unable to find valid credentials in a configuration file and also not able to read a cookie file then we fail and alert the user.

This also fixes a bug introduced in #144 where only passing in a service_url to one of the Proxy classes resulted in an UnboundLocalError like:

Traceback (most recent call last):
  ...
    rpc = bitcoin.rpc.BaseProxy(service_url=url)
  File "/home/sorce/Coding/venvs/test/lib/python3.6/site-packages/bitcoin/rpc.py", line 189, in __init__
    authpair = authpair.encode('utf8')
UnboundLocalError: local variable 'authpair' referenced before assignment

authpair is now checked prior to making the connection and if it is None we assign the parsed username/password from service_url

…ion cookie file even if no configuration file exists
@kanzure
Copy link
Collaborator

kanzure commented Sep 18, 2017

Well, this solves the authpair bug at least.

@xuhcc
Copy link

xuhcc commented Oct 4, 2017

@petertodd

Please take a look at this PR.

RPC interface in version 0.8.0 can't be used due to UnboundLocalError in __init__ method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants